package main
import "fmt"
import "github.com/gocolly/colly"
/*
func main(){
	fmt.Println("Hello,World")
}
*/
func main(){

	// curl   -d "log_time=1528164583&api=login&gid=1&sid=s1&oldsid=s1&user_id=zhangsan&role_id=角色&part_id=1000&time=1528164583&ip=192.168.71.21&role_level=10&map_id=1&group_id=100&login_day=1&gold=10&reg_time=1528164583" "http://localhost:8081"
	fmt.Println("Hello,World")
	c := colly.NewCollector()
  // Visit only domains: hackerspaces.org, wiki.hackerspaces.org 
  c.AllowedDomains = []string{"hackerspaces.org", "wiki.hackerspaces.org"}
  // On every a element which has href attribute call callback
  c.OnHTML("a[href]", func(e *colly.HTMLElement) {
	  link := e.Attr("href")
	  // Print link
	  fmt.Printf("Link found: %q -> %s\n", e.Text, link)
	  // Visit link found on page
	  // Only those links are visited which are in AllowedDomains
	  c.Visit(e.Request.AbsoluteURL(link))
  })
  // Before making a request print "Visiting ..."
  c.OnRequest(func(r *colly.Request) {
	  fmt.Println("Visiting", r.URL.String())
  })
  // Start scraping on https://hackerspaces.org
  c.Visit("https://hackerspaces.org/")
 
}
 